
#include "includes.h"

using namespace std;

void mainloop();
void loadlogo();

int main()
{
    srand(time(0));
    SetConsoleTitle("PAC++MAN");
    SetWindowSize(LEVELHEIGHT + 24, LEVELWIDTH + 35);
    SetCursorVisibility(false);
    player.hiscore = 0;
	loadlogo();
	char choice;
	for (int y = 0;;y++)
	{
		
		SetTextColor(WHITE);
		SetCursorPosition(20, 35);
		cout << "\n\n\t\t\t\t\t\t\tPress any key to play game" << endl;
		Sleep(200);
		SetTextColor(BLUE);
		
		SetCursorPosition(20, 30);
		cout << "\n\n\t\t\t\t\t\t\tPress any key to play game" << endl;
		Sleep(200);
		if (_kbhit()) break;
		
		
	}
	//choice = getche();

	system("cls");
		mainloop();
	
	
	
    return 0;
}

void mainloop()
{
	PlaySound(TEXT("pacman_beginning.wav"), NULL, SND_ASYNC);
    player.score = 0;
    player.lives = 3;
    for(int levelnum = 1; levelnum <= 255; levelnum++)
    {
        loadlevel();
        // while there are still dots on the screen,
		PlaySound(TEXT("pacman_chomp.wav"), NULL, SND_LOOP | SND_ASYNC);
        while(player.left != 0)
        {
			//PlaySound(TEXT("pacman_chomp.wav"), NULL, SND_LOOP | SND_ASYNC);
            player.move();
            moveghosts();
            updatetimers();
        }
        nextlevel();
    }
}

void loadlogo()
{
	PlaySound(TEXT("opening.wav"), NULL, SND_ASYNC);
	SetTextColor(YELLOW);
	cout << "\n\n\n\n\n" << endl;
	cout << "                             _______      ____                               ____     ____              __      _" << endl;
	cout << "                            / ____  \\    / __ \\      _____                  /  _ \\   / _  \\            |  \\    | |" << endl;
	cout << "	                    | |___| |   / /__\\ \\    / ____\\  _       _      | | \\ \\_/ / | |  _______   | |\\\\   | |" << endl;
	cout << "                            |  _____/  /  ____  \\  | /     _| |_   _| |_    | |  \\___/  | | /_  __  |  | | \\\\  | |" << endl;
	cout << "                            | |        | |    | |  | |    |_   _| |_   _|   | |         | |  / /  | |  | |  \\\\ | |" << endl;
	cout << "                            | |        | |    | |  | \\_____ |_|     |_|     | |         | | | /___| |  | |   \\\\| |" << endl;
	cout << "                            |_|        |_|    |_|   \\_____/\                 |_|         |_| |______/\\\\ |_|    \\__|" << endl;
	

	
	SetTextColor(MAGENTA);
	cout << "\n\n\t\t\t\t\t\t\t\t\t\t\t  Created by Shihab, Arif, Mushfiq" << endl;
}
